package com.wl.mall.service.search.controller;

import com.wl.mall.search.entity.SeckillGoodsEs;
import com.wl.mall.service.search.service.SeckillGoodsSearchService;
import com.wl.mall.util.common.entity.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/seckill/goods")
public class SeckillGoodsSearchController {

    @Autowired
    private SeckillGoodsSearchService seckillGoodsSearchService;

    /***
     * 导入数据到索引库
     */
    @PostMapping(value = "/add")
    public RespResult add(@RequestBody SeckillGoodsEs seckillGoodsEs){
        seckillGoodsSearchService.add(seckillGoodsEs);
        return RespResult.ok();
    }

    /****
     * 搜索商品数据
     */
    @GetMapping(value = "/search")
    public RespResult<List<SeckillGoodsEs>> list(@RequestParam("acid")String acid){
        //根据活动ID搜索
        List<SeckillGoodsEs> seckillGoodsEsList =  seckillGoodsSearchService.search(acid);
        return RespResult.ok(seckillGoodsEsList);
    }
}